﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

namespace DukeNUS.FacilitiesPlanning.FPSystem.Models
{
    public class CardAccessRequest
    {

        public CardAccessRequest()
        {
            ReferenceNo = "";
            EffectivityDate = DateTime.Now;
            ExpiryDate = DateTime.Now;
            ApplicantName = "";
            ApplicantCardNo = "";
            ApplicantDesignation = "";
            ApplicantDepartment = "";
            ApplicantEmail = "";
            ApplicantDID = "";
            ApplicantReportingOfficerName = "";
            ApplicantReportingOfficerDesignation = "";
        }

        [Key]
        public int RequestID { get; set; }

        [MaxLength(20)]
        public string ReferenceNo { get; set; }

        [ForeignKey("CardAccessType")]
        public int CATID { get; set; }

        public virtual CardAccessType CardAccessType { get; set; }

        public DateTime EffectivityDate { get; set; }

        public DateTime ExpiryDate { get; set; }

        [ForeignKey("CardAccessApplicantType")]
        public int CAATID { get; set; }

        public virtual CardAccessApplicantType CardAccessApplicantType { get; set; }

        [Required, MaxLength(150)]
        public string ApplicantName { get; set; }

        [Required, MaxLength(30)]
        public string ApplicantCardNo { get; set; }

        [MaxLength(100)]
        public string ApplicantDesignation { get; set; }

        [MaxLength(100)]
        public string ApplicantDepartment { get; set; }

        [MaxLength(100),
        RegularExpression("^(([\\w-]+\\.)+[\\w-]+|([a-zA-Z]{1}|[\\w-]{2,}))@((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" +
                          "[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\\.([0-1]?" +
                          "[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|([a-zA-Z]+[\\w-]+\\.)+[a-zA-Z]{2,4})$")]
        public string ApplicantEmail { get; set; }

        [MaxLength(50)]
        public string ApplicantDID { get; set; }

        [MaxLength(150)]
        public string ApplicantReportingOfficerName { get; set; }

        [MaxLength(100)]
        public string ApplicantReportingOfficerDesignation { get; set; }

        [ForeignKey("User")]
        public int UserID { get; set; }

        public virtual User User { get; set; }

        public IList<CardAccessRequestDetail> CardAccessRequestDetails { get; set; }
 
    }
}